import Model from "../models/classroom";
import Student from '../models/student';

export default class Classroom extends Mod{
  /*
  * 新建一个班级
  * */
  @Api({
    params:{
      title:'string',
    }
  })
  public async set({title}:Context){
    return Model.create({
      title
    })
  }

  /*
  * 获取二班级的所有学生
  * */
  @Api({
    params:{
      classRoomTitle:'string'
    }
  })
  public async getStudentList({classRoomTitle}:Context){
    const classRoomInfo = await Model.where({title:classRoomTitle}).findOne()
    return await Student.where({classroomId:classRoomInfo.id}).findAll()


  }
}